<template>
  <transition name="el-zoom-in-center">
    <div class="jsbos-preview-main">
      <div class="jsbos-common-page-header">
        <el-page-header @back="goBack" content="详情" />
        <div class="options">
          <el-button @click="goBack">取 消</el-button>
        </div>
      </div>
      <el-row
        :gutter="15"
        class="main"
        :style="{ margin: '0 auto', width: '100%' }"
      >
        <div>
          <!-- 下发信息 -->
          <el-card class="box-card">
            <el-descriptions
              class="margin-top"
              title="记录详情"
              :column="5"
              :border="true"
              style="margin-top: 20px"
            >
              <el-descriptions-item
                label="发送渠道"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ dataForm.channelType }}
              </el-descriptions-item>
              <el-descriptions-item
                label="接收人"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ dataForm.sysUserId }}
              </el-descriptions-item>
              <el-descriptions-item
                label="状态"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                <el-tag
                  :type="
                    dataForm.enabledMark == 0
                      ? 'warning'
                      : dataForm.enabledMark == 1
                      ? 'success'
                      : 'danger'
                  "
                  disable-transitions
                >
                  <p>
                    {{ dataForm.enabledMark | dynamicText(enabledMarkOptions) }}
                  </p>
                </el-tag>
              </el-descriptions-item>
              <el-descriptions-item
                label="发送时间"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ jsbos.dateFormat(dataForm.sendTime, "YYYY-MM-DD HH:mm:ss") }}
              </el-descriptions-item>
              <el-descriptions-item
                label="发送人"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ dataForm.sendUserId }}
              </el-descriptions-item>
              <el-descriptions-item
                label="重发时间"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{
                  jsbos.dateFormat(dataForm.againTime, "YYYY-MM-DD HH:mm:ss")
                }}
              </el-descriptions-item>
              <el-descriptions-item
                label="重发人"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ dataForm.againUserId }}
              </el-descriptions-item>
              <el-descriptions-item
                label="是否阅读"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                <template>
                  <el-tag
                    :type="dataForm.isRead == 1 ? 'success' : 'danger'"
                    disable-transitions
                  >
                    {{ dataForm.isRead | dynamicText(isReadOptions) }}
                  </el-tag>
                </template>
              </el-descriptions-item>
              <el-descriptions-item
                label="阅读时间"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ jsbos.dateFormat(dataForm.readTime, "YYYY-MM-DD HH:mm:ss") }}
              </el-descriptions-item>
              <el-descriptions-item
                label="阅读次数"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ dataForm.readCount }}
              </el-descriptions-item>
              <el-descriptions-item
                label="备注描述"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="5"
              >
                {{ dataForm.description }}
              </el-descriptions-item>
            </el-descriptions>
            <el-descriptions
              class="margin-top"
              title="消息内容"
              :column="2"
              :border="true"
              style="margin-top: 20px"
            >
              <el-descriptions-item
                label="类型"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                <p>
                  {{ taskMsgContentInfo.contentType }}
                </p>
              </el-descriptions-item>
              <el-descriptions-item
                label="标题"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ taskMsgContentInfo.title }}
              </el-descriptions-item>
              <el-descriptions-item
                label="内容"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="2"
              >
                <p>
                  {{ taskMsgContentInfo.content }}
                </p>
              </el-descriptions-item>
              <el-descriptions-item
                label="消息链接"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="2"
              >
                <p>
                  {{ taskMsgContentInfo.linkUrl }}
                </p>
              </el-descriptions-item>
              <el-descriptions-item
                label="图片链接"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="2"
              >
                <p>
                  {{ taskMsgContentInfo.picUrl }}
                </p>
              </el-descriptions-item>
            </el-descriptions>
            <el-descriptions
              class="margin-top"
              title="业务消息"
              :column="4"
              :border="true"
              style="margin-top: 20px"
            >
              <el-descriptions-item
                label="业务系统"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ taskMsgInfo.taskCode }}
              </el-descriptions-item>
              <el-descriptions-item
                label="发送配置"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ taskMsgInfo.sendCode }}
              </el-descriptions-item>
              <el-descriptions-item
                label="创建时间"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{
                  jsbos.dateFormat(
                    taskMsgInfo.creatorTime,
                    "YYYY-MM-DD HH:mm:ss"
                  )
                }}
              </el-descriptions-item>
              <el-descriptions-item
                label="创建人"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ taskMsgInfo.creatorUserId }}
              </el-descriptions-item>
              <el-descriptions-item
                label="关键参数"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="4"
              >
                <p>
                  {{ taskMsgInfo.businessKey }}
                </p>
              </el-descriptions-item>
              <el-descriptions-item
                label="自定义参数"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="4"
              >
                <p>
                  {{ taskMsgInfo.customKey }}
                </p>
              </el-descriptions-item>
            </el-descriptions>
            <el-descriptions
              class="margin-top"
              title="发送配置"
              :column="2"
              :border="true"
              style="margin-top: 20px"
            >
              <el-descriptions-item
                label="发送配置名称"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ msgSendConfig.fullName }}
              </el-descriptions-item>
              <el-descriptions-item
                label="发送配置编码"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                <p>
                  {{ msgSendConfig.enCode }}
                </p>
              </el-descriptions-item>
              <el-descriptions-item
                label="场景名称"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ msgSendConfig.messageSourceName }}
              </el-descriptions-item>
              <el-descriptions-item
                label="场景编码"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ msgSendConfig.messageSource }}
              </el-descriptions-item>
              <el-descriptions-item
                label="模板名称"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ sendTemplateModel.templateName }}
              </el-descriptions-item>
              <!-- <el-descriptions-item
                label="模板类型"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
              >
                {{
                  msgSendConfig.templateType | dynamicText(templateTypeOptions)
                }}
              </el-descriptions-item> -->
              <el-descriptions-item
                label="模板编码"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ sendTemplateModel.templateEnCode }}
              </el-descriptions-item>
              <el-descriptions-item
                label="应用名称"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ sendTemplateModel.accountName }}
              </el-descriptions-item>
              <el-descriptions-item
                label="应用编码"
                :contentStyle="contentStyle"
                :labelStyle="labelStyle"
                :span="1"
              >
                {{ sendTemplateModel.accountEnCode }}
              </el-descriptions-item>
            </el-descriptions>
          </el-card>
        </div>
      </el-row>
    </div>
  </transition>
</template>
<script>
getDetail;
import { getDetail } from "@/views/message/api/mcTaskMsgReceive";
import { getDetail as getMcTaskMsgContent } from "@/views/message/api/mcTaskMsgContent";
import { getDetail as getMcTaskMsg } from "@/views/message/api/mcTaskMsg";
import { getInfoByEnCode as getMcMsgSend } from "@/views/message/api/mcMsgSend";
export default {
  components: {},
  props: [],
  data() {
    return {
      //内容样式
      contentStyle: {
        "text-align": "left",
      },
      //label样式
      labelStyle: { width: "120px" },
      visible: false,
      loading: false,
      printId: "",
      dataForm: {},
      taskMsgInfo: {},
      taskMsgContentInfo: {},
      msgSendConfig: {},
      sendTemplateModel: {},
      enabledMarkOptions: [
        { fullName: "发送失败", id: "2" },
        { fullName: "发送成功", id: "1" },
        { fullName: "待下发", id: "0" },
      ],
      isReadOptions: [
        { fullName: "是", id: "1" },
        { fullName: "否", id: "0" },
      ],
      templateTypeOptions: [
        { fullName: "自定义模板", id: "0" },
        { fullName: "系统模板", id: "1" },
      ],
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    dataInfo(dataAll) {
      let _dataAll = dataAll;
      this.dataForm = _dataAll;
    },

    goBack() {
      this.$emit("refresh");
    },
    init(id) {
      this.dataForm.id = id || 0;
      this.visible = true;
      this.$nextTick(() => {
        if (this.dataForm.id) {
          this.loading = true;
          getDetail(this.dataForm.id).then((res) => {
            this.queryMcTaskMsgContent(res.data.contentId);
            this.queryMcTaskMsg(res.data.msgId);
            this.dataInfo(res.data);
            this.loading = false;
          });
        }
      });
    },
    queryMcTaskMsgContent(contentId) {
      getMcTaskMsgContent(contentId).then((res) => {
        this.taskMsgContentInfo = res.data;
      });
    },
    queryMcTaskMsg(msgId) {
      getMcTaskMsg(msgId).then((res) => {
        this.taskMsgInfo = res.data;
        this.querygetMcMsgSend(res.data.sendCode);
      });
    },
    querygetMcMsgSend(sendCode) {
      getMcMsgSend(sendCode).then((res) => {
        this.msgSendConfig = res.data;
        if (res.data && res.data.sendTemplateList) {
          res.data.sendTemplateList.map((o) => {
            if (o.id == this.dataForm.templateId) {
              this.sendTemplateModel = o;
              return;
            }
          });
        }
      });
    },
  },
};
</script>
